package com.hbk.codemaker;
import java.awt.Color;
import java.awt.Component;
import java.util.ArrayList;
import java.util.HashMap;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;

import com.hbk.programe.Param;


public class NodeRenderer extends DefaultTreeCellRenderer {

  String imagePath="lib/images/";
  HashMap<String, Icon> icons;
  ArrayList<String> iconNames=new ArrayList<>();

  public NodeRenderer() {
    icons=new HashMap<String, Icon>();
    iconNames.add("class.png");
    iconNames.add("field.png");
    for(String icon:iconNames){
    	Icon iconImage=new ImageIcon(imagePath+icon);
        icons.put(icon, iconImage);
    }
  }

  @Override
  public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
    
//    if(leaf) {
//    	Icon icon=icons.get("field.png");
//		setIcon(icon);
//    }else {
//    	Icon icon=icons.get("class.png");
//		setIcon(icon);
//    }
    setIcon(null);
    setBackgroundNonSelectionColor(new Color(247, 247, 247));
    return this;
  }

}
